/* Filename: main.c
 * Description: <TODO>
 * Last modified: humble 2020-09-24 11:46:25
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include "anytimer.h"

static void usage(void);

static void f1(void *arg) { printf("f1() :%s\n", (char *)arg); }

static void f2(void *arg) { printf("f2() :%s\n", (char *)arg); }

int main(int argc, char **argv)
{
    int job1, job2, job3;

    if(argc != 1){ fprintf(stderr, "argc !=1"); usage(); exit(1); }

    puts("begin");

#if 1
    job1 = at_addjob_repeat(2, f1, "aaa");
    if(job1 < 0){ fprintf(stderr, "at_addjob():%s\n", strerror(-job1)); }
#else
    job1 = at_addjob(5, f1, "aaa");
    if(job1 < 0){ fprintf(stderr, "at_addjob():%s\n", strerror(-job1)); }

    job2 = at_addjob(2, f2, "bbb");
    if(job2 < 0){ fprintf(stderr, "at_addjob():%s\n", strerror(-job2)); }

    job3 = at_addjob(7, f1, "ccc");
    if(job3 < 0){ fprintf(stderr, "at_addjob():%s\n", strerror(-job3)); }
#endif

    puts("end");

    while(1){
        write(1, ".", 1);
        sleep(1);
    }
    return 0;
}

static void usage(void)
{
#define USAGE "Usage:\n\
  Helloworld\n"
    printf(USAGE);
}
